package org.example.misc.exception;

import org.example.misc.model.IResultCode;

/**
 * 业务异常
 */
public class ServiceException extends RuntimeException {
    private String errorCode;

    public ServiceException(IResultCode resultCode) {
        super(resultCode.getMsg());
        this.errorCode = resultCode.getCode();
    }

    public ServiceException(IResultCode resultCode, String params) {
        super(String.format(resultCode.getMsg(), params));
        this.errorCode = resultCode.getCode();
    }

    public ServiceException(String code, String message) {
        super(message);
        this.errorCode = code;
    }

    public ServiceException(String code, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = code;
    }

    public String getErrorCode() {
        return errorCode;
    }
}

